package com.koron.configure.changeshift.controller;


import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.configure.changeshift.bean.ChangeShiftCFDto;
import com.koron.configure.changeshift.mapper.ChangeShiftCFMapper;
import com.koron.configure.changeshift.service.ChangeShiftCFService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "交接班配置 废弃", hidden = true)
@RestController
@RequestMapping("/changeShiftcf")
public class ChangeShiftCFController {

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @Autowired
    private ChangeShiftCFService service;

    @ApiOperation(value = "交接班配置-列表")
    @GetMapping("queryList")
    public Response<List<ChangeShiftCFDto>> queryList(ChangeShiftCFDto dto) {
        List<ChangeShiftCFDto> list = ADOConnection.runTask(getCurrDs(), service, "queryList", List.class, dto);
        return Response.ok(list);
    }


    @ApiOperation(value = "交接班配置-新建")
    @GetMapping("addChangeShiftCF")
    public Response<String> addChangeShiftCF(ChangeShiftCFDto dto) {
        String id = ADOConnection.runTask(getCurrDs(), service, "addChangeShiftCF", String.class, dto);
        return Response.ok(id);
    }

    @ApiOperation(value = "交接班配置-更新")
    @GetMapping("updateChangeShiftCF")
    public Response<String> updateChangeShiftCF(ChangeShiftCFDto dto) {
        ADOConnection.runTask(getCurrDs(), service, "updateChangeShiftCF", String.class, dto);
        return Response.ok(dto.getId());
    }


    @ApiOperation(value = "交接班配置-删除")
    @DeleteMapping("deleteById")
    public Response<String> deleteById(@RequestParam(value = "id") String id) {
        ADOConnection.runTask(getCurrDs(), factory -> factory.getMapper(ChangeShiftCFMapper.class).deleteByPrimaryKey(id), Integer.class);
        return Response.ok("成功");
    }

}
